PROJECT(IPMsg C)

MACRO(PROJECT_VERSION MAJOR MINOR PATCH)
	SET(CPACK_PACKAGE_VERSION_MAJOR ${MAJOR})
	SET(CPACK_PACKAGE_VERSION_MINOR ${MINOR})
	SET(CPACK_PACKAGE_VERSION_PATCH ${PATCH})
INCLUDE(CPack)
	MESSAGE("Building Makefile for ${CMAKE_PROJECT_NAME} ${CPACK_PACKAGE_VERSION}")
	ADD_DEFINITIONS(
			-DPACKAGE="\\"${CMAKE_PROJECT_NAME}\\""
			-DPACKAGE_NAME="\\"${CMAKE_PROJECT_NAME}\\""
			-DPACKAGE_VERSION_ID="${MAJOR}<<16|${MINOR}<<8|${PATCH}"
			-DPACKAGE_VERSION_STRING="\\"${CPACK_PACKAGE_VERSION}\\""
			-DVERSION="\\"${CPACK_PACKAGE_VERSION}\\""
			)
	ENDMACRO(PROJECT_VERSION)
INCLUDE(UsePkgConfig)

PROJECT_VERSION(1 0 0)

PKGCONFIG(gaim LIBGAIM_INCLUDE_DIR LIBGAIM_LINK_DIR LIBGAIM_LINK_FLAGS LIBGAIM_CFLAGS)
IF("${LIBGAIM_INCLUDE_DIR}" STREQUAL "")
	MESSAGE(FATAL_ERROR "gaim not found")
ENDIF("${LIBGAIM_INCLUDE_DIR}" STREQUAL "")

SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBGAIM_CFLAGS} -Wall")

ADD_LIBRARY(ipmsg SHARED ipmsg.c)
